package com.aaa.controller;

import com.aaa.entity.TabClass;
import com.aaa.entity.TabStu;
import com.aaa.service.ITabStuService;
import com.aaa.util.Result;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author 于永利
 * @since 2024-08-10
 */
@RestController
@RequestMapping("/tab-stu")
@CrossOrigin
public class TabStuController {

    // 查询所有的学生以及学生对应的班级
    //
    @Autowired
    private ITabStuService tabStuService;

    @GetMapping
    public Result findAll(Integer currentPage, Integer pageSize, TabClass tabClass){
        IPage page= new Page(currentPage,pageSize);

        return Result.success(tabStuService.queryStu(page,tabClass));
    }


    @PostMapping
    public Result addStu(@RequestBody TabStu tabStu){

        return Result.success(tabStuService.saveOrUpdate(tabStu));
    }

    @DeleteMapping
    public Result addStu(Integer id){

        return Result.success(tabStuService.removeById(id));
    }

}
